#!/usr/bin/env node

const chalk = require('chalk');
const {execSync} = require('child_process')

console.log(chalk.yellow(`
┌══════════════════════════════════════════════════┐

  警告：clean 将自动执行以下两项操作
  
  1. ${chalk.red('git reset --hard')}   删除所有未提交的更改
  2. ${chalk.red('git clean -d  -f')}   删除所有未跟踪的文件及文件夹

  !!! 请确保 您的更改已提交

└══════════════════════════════════════════════════┘
`))


const cmd = `

read -p " 任意键退出, y 键执行" -n 1 -r
echo    # (optional) move to a new line

if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 0
fi

echo

git reset --hard && git clean -d  -f

echo
`

execSync(cmd, {stdio: 'inherit'})
